package com.yzl.nacos.user.common.entity;

import com.yzl.nacos.user.common.enums.ErrorCodeEnum;

public class RestResponse {
 
    private int code;
    private String msg;
    private Object data;
 
 
    public static RestResponse success() {
        return new RestResponse();
    }
 
    public static RestResponse error(ErrorCodeEnum errorCode) {
        RestResponse restResponse = new RestResponse(errorCode.getCode(), errorCode.getMsg());
        return restResponse;
    }
 
    public RestResponse() {
        //默认会调用有参的构造函数,默认是成功的
        this(0, "success");
    }
 
    public RestResponse(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
 
    public RestResponse(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }
 
 
    public RestResponse(Object data) {
    	this(0, "success",data);
    }
 
    public int getCode() {
        return code;
    }
 
    public void setCode(int code) {
        this.code = code;
    }
 
    public String getMsg() {
        return msg;
    }
 
    public void setMsg(String msg) {
        this.msg = msg;
    }
 
    public Object getData() {
        return data;
    }
 
    public void setData(Object data) {
        this.data = data;
    }
}